/*
 * @Author: WangLi
 * @Date: 2021-07-22 09:43:32
 * @LastEditors: WangLi
 * @LastEditTime: 2021-07-27 13:10:16
 * @Description:
 */
import { button } from "../../mixins/button";
Component({
  behaviors: [button],
  externalClasses: ["custom-class"],
  options: {
    multipleSlots: true,
    addGlobalClass: true,
  },
  properties: {
    formType: String,
    icon: String,
    plain: Boolean,
    block: Boolean,
    round: Boolean,
    square: Boolean,
    loading: Boolean,
    disabled: Boolean,
    loadingText: String,
    customStyle: String,
    loadingType: {
      type: String,
      value: "circular",
      options: ["circular", "spinner"],
    },
    type: {
      type: String,
      value: "default",
      options: ["primary", "warning", "success", "error", "default"],
    },
    dataset: null,
    size: {
      type: String,
      value: "normal",
      options: ["normal", "small", "large", "mini"],
    },
    loadingSize: {
      type: String,
      value: 36,
    },
    color: String,
  },
  data: {},
  methods: {
    onClick(event) {
      this.triggerEvent("click", event.detail);

      const { canIUseGetUserProfile, openType, getUserProfileDesc } = this.data;

      if (openType === "getUserInfo" && canIUseGetUserProfile) {
        wx.getUserProfile({
          desc: getUserProfileDesc || "  ",
          complete: (userProfile) => {
            this.triggerEvent("getuserinfo", userProfile);
          },
        });
      }
    },
  },
});
